package dao_Impl;

import interfaces.DALException;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.mysql.jdbc.Connection;

import connector.Connector;
import dao_Impl.MySQLBookDAO;
import dto_objects.AuthorDTO;
import dto_objects.BookDTO;

public class TST {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			new connector.Connector();
		} catch (InstantiationException | IllegalAccessException
				| ClassNotFoundException | SQLException e) {
			e.printStackTrace();
		}
		
		MySQLSearchDAO testSearch = new MySQLSearchDAO();
		try {
			List<ArrayList> temp = testSearch.quickSearch("");
			List<BookDTO> bookTemp = (List<BookDTO>)temp.get(0);
			System.out.println(bookTemp.size());
			
			for (BookDTO emp : (List<BookDTO>)temp.get(0)) {
				System.out.println(emp.getTitle());
				for (AuthorDTO author : emp.getAuthors()) {
					System.out.println("\t" + author.getAuthorFirstName() + " " + author.getAuthorLastName());
				}
				System.out.println();
				System.out.println(emp.getAuthorNames());
				System.out.println();
			}
			for (AuthorDTO emp : (List<AuthorDTO>)temp.get(1)) {
				System.out.println(emp.getAuthorFirstName());
			}
			System.out.println("YES!");
		} catch (DALException | SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}	
		

}
